package dt.inlee.common.encoder;


//import org.jasig.cas.authentication.handler.PasswordEncoder;
/**
 * @功能：用于CAS加密验证
 * @作者：ckdong
 * @创建日期：2012-4-27
 */
//需实现PasswordEncoder接口的encode()方法
//public class CASPasswordEncoder implements PasswordEncoder{
public class CASPasswordEncoder{ 
	 public String encode(String strSource){
	       String strR = null;
	       try {
//	           strR = DigestUtil.digestString(strSource, "SHA");
	           strR = DESUtil.getInstance().encrypt(strSource);
	       } catch (Exception e) {
	           e.printStackTrace();
	       }
	       return strR;
	    }
	 public static void main(String[] args) {
//		 CASPasswordEncoder c = new CASPasswordEncoder();
//		 System.out.println(c.encode("admin"));
//		double two=15;
//		double three=26;
//		double a = two/three;
//		DecimalFormat df1 = new DecimalFormat("###%");    
//		System.out.println(df1.format(a));
			String path ="http://123.145.100.49:8058/expApp/test.jsp";
			String igpath = path.substring(0,path.lastIndexOf(":") );
			System.out.println(igpath);
//		 CASPasswordEncoder.class.getClassLoader()
//			InputStream inputStream = CASPasswordEncoder.class.getResourceAsStream("cas.properties");
//			Properties p = new Properties();    
//			try {    
//			p.load(inputStream);    
//			} catch (IOException e1) {    
//			e1.printStackTrace();    
//			}   
//			System.out.println("host.name:"+p.getProperty("host.name")+",port:"+p.getProperty("port")); 
////			
//			Properties  propertie = new Properties();
//		        try {
//		        	String r = CASPasswordEncoder.class.getResource("/").getPath(); 
//		        	String igpath = r.substring(0,r.lastIndexOf("/")-8);
//		        	FileInputStream inputFile = new FileInputStream(igpath+"/WEB-INF/cas.properties");
//		            propertie.load(inputFile);
//		            inputFile.close();
//		        } catch (FileNotFoundException ex){
//		            System.out.println("读取属性文件--->失败！- 原因：文件路径错误或者文件不存在");
//		            ex.printStackTrace();
//		        } catch (IOException ex){
//		            System.out.println("装载文件--->失败!");
//		            ex.printStackTrace();
//		        }
//		        System.out.println("host.name:"+propertie.getProperty("host.name")+",port:"+propertie.getProperty("port")); 
	}
	// 6bf61d6a74235662
}
